<template>
	<view :style="theme">
		<!-- #ifdef MP-WEIXIN -->
		<u-navbar :placeholder="true">
			<view slot="left" class="nav_title">
				<text style="z-index: 10;">活动</text>
			</view>
		</u-navbar>
		<!-- #endif -->
		<view style="height: 30rpx;"></view>
		<HdList :list="list" />
		<u-loadmore v-if="end && list.length >= 10" :status="status" line />
		<view v-if="list.length === 0" class="no-order">
			<image :src="imgHost+'/default_nodata.png'"></image>
			<view>暂无活动～</view>
		</view>
	</view>
</template>

<script>
	import HdList from "@/components/hdList.vue";
	export default {
		components: {
			HdList
		},
		data() {
			return {
				tabIndex: '/pages/activity/index',
				list: [],
				page: 1,
				end: false,
				firstQueryTime: '',
				status: 'nomore',
			}
		},
		mounted() {
			//监听下拉加载更多
			let that = this
			uni.$on('onReachBottom', () => {
				that.reachBottom()
			})
		},
		beforeDestroy() {
			uni.$off('onReachBottom');
			uni.$off('onPageScroll');
		},
		methods: {
			jump(url, params, a) {
				this.$app.jump(url, params, a);
			},
			jump2(url, params, a) {
				this.$app.jump2(url, params, a);
			},
			searchBtn() {
				this.firstQueryTime = this.$app.firstQueryTime()
				this.list = [];
				this.page = 1;
				this.end = false;
				this.getList()
			},
			getList() {
				this.$app.ajax({
					data: {
						pagination: {
							firstQueryTime: this.firstQueryTime,
							page: this.page,
							rows: 10
						},
						param: {
							venueId: this.venueId
						}
					},
					api: this.$api.activityListMini()
				}).then((res) => {
					if (res.errorCode === '000000') {
						if (!res.recordList || res.recordList.length < 10) {
							this.end = true
						}
						if (res.recordList) {
							this.list = this.list.concat(res.recordList)
						}
					}
				}).catch(() => {})
			},
			reachBottom() {
				if (!this.end) {
					this.page += 1;
					this.getList();
				}
			}

		}

	}
</script>
